import load

class company:
    def __init__(self,code):
        self.code=code
        self.allXiao={}
        self.maxDay=99999
        self.minDay=0

    def addXiao(self,danwei,day):
        if not danwei in self.allXiao.keys():
            self.allXiao[danwei]=set()
        self.allXiao[danwei].add(day)
        if day>self.maxDay:
            self.maxDay=day
        if day<self.minDay:
            self.minDay=day

    def calu(self):
        tot = self.maxDay-self.minDay
        t=0
        for danwei,s in self.allXiao.items():
            t+=len(s)
        return t/tot

allCompany={}

for i in range(1, 162485):
    code = load.getCell(i, load.code, False)
    if not code in allCompany.keys():
        allCompany[code]=company(code)
    danwei = load.getCell(i, load.danwei, False)
    day = float(load.getCell(i, load.date, False))
    allCompany[code].addXiao(danwei, day)

print('企业代号,回头')
for name,comp in allCompany.items():
    print(name+','+str(comp.calu()))